{include file="public/layout" /}

<body class="eyou_body_xin">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>

{include file="system/left" /}
<div id="geduan_div" class="h15"></div>
<div class="page" style="min-width:auto;margin-left:115px;padding-bottom: 15px;">
    <div class="fixed-bar">
        <div class="item-title">
            <a class="back_xin" href="javascript:history.back();" title="返回"><i class="iconfont e-fanhui"></i></a>
            <div class="subject">
                <h3>编辑帮助分类</h3>
                <h5></h5>
            </div>
            <!-- <ul class="tab-base nc-row">
                <li><a href="javascript:void(0);" data-index='1' class="tab current"><span>常规选项</span></a></li>
                <li><a href="javascript:void(0);" data-index='2' class="tab"><span>高级选项</span></a></li>
            </ul> -->
        </div>
    </div>
    <form class="form-horizontal" id="post_form" action="{:url('Help/arctype_edit')}" method="post">
        <!-- 常规选项 -->
        <div class="ncap-form-default tab_div_1">
        <dl class="row">
            <dt class="tit">
                <label for="typename"><em>*</em>分类名称</label>
            </dt>
            <dd class="opt">
                <input type="text" value="{$field.typename|default=''}" name="typename" id="name" class="input-txt">
                <!-- <p class="notic">保持唯一性，不可重复</p> -->
            </dd>
        </dl>
        <!-- <dl class="row {if 51 == $field['current_channel'] || $is_diyseo_htmlpath == 1} none {/if} " id="dl_dirname">
            <dt class="tit">
                <label for="dirname">目录名称</label>
            </dt>
            <dd class="opt">
                <input type="text" value="{$field.dirname|default=''}" name="dirname" id="dirname" class="input-txt" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9_-]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-zA-Z0-9_-]/g,''));">
                <p class="notic">用于伪静态和静态页面生成！</p>
                <p class="">留空系统默认全拼音+随机数，仅支持字母、数字、下划线、连接符</p>
            </dd>
        </dl> -->

        <dl class="row">
            <dt class="tit"> <label for="parent_id">上级分类</label> </dt>
            <dd class="opt">
                <select class="small form-control" id="parent_id" name="parent_id">
                    <option value="{$type_id}" selected="true">顶级分类</option>
                    {volist name="arctype_list2" id="vo"}
                    <option value="{$vo.id}" {eq name="$parent_id" value="$vo.id"}selected="true"{/eq}>{$vo.typename}</option>
                    {/volist}
                </select>
            </dd>
        </dl>

        <!-- <dl class="row"  id="dl_typearcrank" {eq name="$field.current_channel" value="6"}style="display:none"{/eq}>
            <dt class="tit">
                <label>阅读权限</label>
            </dt>
            <dd class="opt">
                <input type="hidden" value="{$field.typearcrank}" name="old_arcrank" class="input-txt">
                <select name="typearcrank" id="typearcrank" {if $field.typearcrank < 0 && $admin_info.role_id > 0 && $auth_role_info.check_oneself < 1} disabled="disabled" {/if}>
                {volist name="arcrank_list" id="vo"}
                <option value="{$vo.rank}" {eq name="$vo.rank" value="$field.typearcrank"}selected{/eq}>{$vo.name}</option>
                {/volist}
                </select>
                <span class="err"></span>
                <p class="notic">仅限制栏目里的文档阅读权限</p>
            </dd>
        </dl> -->
        <!-- #weapp_UsersGroup_content# -->
        <input type="hidden" name="channeltype" id="channeltype" value="{$field.channeltype|default=''}" />
        <!-- <dl class="row {if $is_diyseo_htmlpath == 0} none {/if}">
            <dt class="tit">
                <label for="diy_dirpath">文件保存目录</label>
            </dt>
            <dd class="opt">
                {$seo_html_arcdir}<input type="text" value="{$field.diy_dirpath}" name="diy_dirpath" id="diy_dirpath" class="w350" onkeyup="this.value=this.value.replace(/[^0-9a-zA-Z\/-]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9a-zA-Z\/-]/g,''));">
                &nbsp;<a href="javascript:void(0);" onclick="get_dirpinyin(this);" id="getpinyin" class="ncap-btn ncap-btn-green">获取拼音</a>
                <p class="notic">生成的文章HTML页面会存放在该目录下</p>
            </dd>
        </dl> -->
        <!-- <dl class="row none">
            <dt class="tit">
                <label for="dirpath">文件保存目录</label>
            </dt>
            <dd class="opt">
                {$seo_html_arcdir}<input type="text" value="{$predirpath}" name="dirpath" id="dirpath" class="w350" onkeyup="this.value=this.value.replace(/[^0-9a-zA-Z\/-]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9a-zA-Z\/-]/g,''));">
                <p class="notic">生成的文章HTML页面会存放在该目录下</p>
            </dd>
        </dl> -->
        <!-- <dl class="row">
            <dt class="tit">
                <label>隐藏栏目</label>
            </dt>
            <dd class="opt">
                <label class="curpoin"><input id="is_hidden1" name="is_hidden" value="1" type="radio" {if condition="$field.is_hidden eq 1"} checked="checked"{/if}>是</label>
                &nbsp;
                <label class="curpoin"><input id="is_hidden0" name="is_hidden" value="0" type="radio" {if condition="$field.is_hidden eq 0"} checked="checked"{/if}>否</label>
                <p class="notic">隐藏之后，不显示在前台页面</p>
            </dd>
        </dl> -->

        {if condition="!empty($field['weapp_code'])"}
        <div class="none">
            {/if}

            {include file="field/addonitem" /}

            {if condition="!empty($field['weapp_code'])"}
        </div>
        {/if}

</div>
<!-- 常规选项 -->
<!-- 高级选项 -->
<div class="ncap-form-default tab_div_2 none">
    <dl class="row {if condition="!empty($field['weapp_code']) || 51 == $field['current_channel']"}none{/if}" id="type_attr">
        <dt class="tit">
            <label>栏目属性</label>
        </dt>
        <dd class="opt">
            <label class="curpoin"><input id="is_part0" name="is_part" value="0" type="radio" {if condition="$field.is_part eq 0"} checked="checked"{/if}>内容栏目</label>
            &nbsp;
            <label class="curpoin"><input id="is_part1" name="is_part" value="1" type="radio" {if condition="$field.is_part eq 1"} checked="checked"{/if}>外部链接</label>
            <p class="notic">外部连接（在"下方文本框"处填写网址）</p>
        </dd>
    </dl>
    <div class="{eq name='$field.is_part' value='0'}none{/eq}" id="row_url">
        <dl class="row">
            <dt class="tit">
                <label for="typelink"><em>*</em>外部链接</label>
            </dt>
            <dd class="opt">
                <input type="text" value="{$field.typelink|default=''}" name="typelink" id="typelink" class="input-txt" placeholder="http://">
                <p class="notic">请填写完整外部链接</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>链接属性</label>
            </dt>
            <dd class="opt">
                <label><input type="checkbox" name="target" value="1" {if condition="$field.target eq 1"}checked="checked"{/if}>新窗口打开</label>&nbsp;&nbsp;
                <label><input type="checkbox" name="nofollow" value="1" {if condition="$field.nofollow eq 1"}checked="checked"{/if}>nofollow</label>&nbsp;&nbsp;
                <a href="javascript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=17589','链接属性使用教程')">查看标签使用教程</a>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
    </div>
<dl class="row">
    <dt class="tit">
        <label for="englist_name">英文别名</label>
    </dt>
    <dd class="opt">
        <input type="text" value="{$field.englist_name|default=''}" name="englist_name" id="englist_name" class="input-txt">
        <p class="notic">显示英文名栏目的网站</p>
    </dd>
</dl>

    <dl class="row">
        <dt class="tit">
            <label>栏目图片</label>
        </dt>
        <dd class="opt">
            <div class="input-file-show div_litpic_local" {neq name="$field.is_remote" value="0"}style="display: none;"{/neq}>
            <span class="show">
                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="{$field.litpic_local|default='javascript:void(0);'}" target="_blank">
                    <i id="img_i" class="fa fa-picture-o" {notempty name="$field.litpic_local"}onmouseover="layer_tips=layer.tips('<img src={$field.litpic_local} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                </a>
            </span>
            <span class="type-file-box">
                <input type="text" id="litpic_local" name="litpic_local" value="{$field.litpic_local|default=''}" class="type-file-text" autocomplete="off">
                <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                <input class="type-file-file" onClick="GetUploadify(1,'','allimg','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo"
                       title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
            </span>
            </div>
            <input type="text" id="litpic_remote" name="litpic_remote" value="{$field.litpic_remote|default=''}" placeholder="http://" class="input-txt" {neq name="$field.is_remote" value="1"}style="display: none;"{/neq}>
            &nbsp;
            <label><input type="checkbox" name="is_remote" id="is_remote" value="1" {eq name="$field.is_remote" value="1"}checked="checked"{/eq} onClick="clickRemote(this, 'litpic');">远程图片</label>
            <span class="err"></span>
            <p class="notic"></p>
        </dd>
    </dl>
    <dl class="row" id="dl_templist">
        <dt class="tit">
            <label for="templist"><em>*</em>栏目模板</label>
        </dt>
        <dd class="opt">
            <select name="templist" id="templist">
            </select>
            <span class="err"></span>
            <p class="notic">模板命名规则：<br/>lists_<font class="font_nid">模型标识</font>.htm<br/>lists_<font class="font_nid">模型标识</font>_自定义.htm</p>
            &nbsp;<a href="javascript:void(0);" onclick="newtpl('lists');" class="ncap-btn ncap-btn-green">新建模板</a>
        </dd>
    </dl>
    <dl class="row" id="dl_tempview">
        <dt class="tit">
            <label for="tempview"><em>*</em>文档模板</label>
        </dt>
        <dd class="opt">
            <select name="tempview" id="tempview">
            </select>
            <span class="err"></span>
            <p class="notic">模板命名规则：<br/>view_<font class="font_nid">模型标识</font>.htm<br/>view_<font class="font_nid">模型标识</font>_自定义.htm</p>
            &nbsp;<a href="javascript:void(0);" onclick="newtpl('view');" class="ncap-btn ncap-btn-green">新建模板</a>
        </dd>
    </dl>
    <dl class="row {if $is_diyseo_htmlpath == 0 || $seo_html_listname != 4} none {/if}" id="dl_rulelist">
        <dt class="tit">
            <label for="dirpath">栏目名规则</label>
        </dt>
        <dd class="opt">
            <input type="text" value="{$field.rulelist|default=$rulelist}" name="rulelist" id="rulelist" class="input-txt" >
            <p class="notic2">1、{tid} 栏目ID<span id="rule_tips_2"><br/>2、{page} 栏目的页码，如果没有该变量，第1页以后的html页面将不存在</span></p>
        </dd>
    </dl>
    <dl class="row {if condition="in_array($field['current_channel'], [6,8]) OR ($is_diyseo_htmlpath == 0 OR $seo_html_pagename != 4)"} none {/if}" id="dl_ruleview">
        <dt class="tit">
            <label for="dirpath">文档名规则</label>
        </dt>
        <dd class="opt">
            <input type="text" value="{$field.ruleview|default=$ruleview}" name="ruleview" id="ruleview" class="input-txt" >&nbsp;
            <p class="notic2">1、{Y}、{M}、{D} 年月日<br/>2、{aid} 文档ID</p>
        </dd>
    </dl>
    <dl class="row">
        <dt class="tit">
            <label for="seo_title">SEO标题</label>
        </dt>
        <dd class="opt">
            <input type="text" value="{$field.seo_title|default=''}" name="seo_title" id="seo_title" class="input-txt">
            <p class="notic"></p>
        </dd>
    </dl>
    <dl class="row">
        <dt class="tit">
            <label>SEO关键字</label>
        </dt>
        <dd class="opt">
            <textarea rows="5" cols="60" id="seo_keywords" name="seo_keywords" style="height:40px;">{$field.seo_keywords|default=''}</textarea>
            <span class="err"></span>
            <p class="notic">多个关键词请用英文逗号（,）隔开，建议3到5个关键词。</p>
        </dd>
    </dl>
    <dl class="row">
        <dt class="tit">
            <label>SEO描述</label>
        </dt>
        <dd class="opt">
            <textarea rows="5" cols="60" id="seo_description" name="seo_description" style="height:60px;">{$field.seo_description|default=''}</textarea>
            <span class="err"></span>
            <p class="notic"></p>
        </dd>
    </dl>
    <!--<dl class="row {eq name="$field['current_channel']" value="51"}none{/eq}" >-->
        <!--<dt class="tit">继承选项</dt>-->
        <!--<dd class="opt">-->
            <!--<label class="label"><input class="check" type="checkbox" name="inherit_status" value="1">&nbsp;同时更改下级栏目的模板风格、命名规则</label>-->
        <!--</dd>-->
    <!--</dl>-->
</div>
<!-- 高级选项 -->
    <div class="ncap-form-default">
        <div class="bot">
            <input type="hidden" name="id" id="id" value="{$field.id|default=''}">
            <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
        </div>
    </div>
</form>
</div>
<script type="text/javascript">

    var templateList = {$templateList|json_encode};

    $(document).ready(function(){
        //选项卡切换列表
        $('.tab-base').find('.tab').click(function(){
            $('.tab-base').find('.tab').each(function(){
                $(this).removeClass('current');
            });
            $(this).addClass('current');
            var tab_index = $(this).data('index');
            $(".tab_div_1, .tab_div_2").hide();
            $(".tab_div_"+tab_index).show();
        });

        $('input[name=is_part]').click(function(){
            var val = $(this).val();
            if (val == 1) {
                $('#row_url').show();
            } else {
                $('#row_url').hide();
            }
        });

        // ajax_get_template();
    });

    /*根据模型ID获取模板文件名*/
    function ajax_get_template() {
        var is_diyseo_htmlpath = {$is_diyseo_htmlpath|default=0};
        var channel = 1;
        var js_allow_channel_arr = {$js_allow_channel_arr};
        $('#notic_current_channel').html('');
        if (51 == channel){
            $("#type_attr").hide();
            $('#dl_dirname').hide();
        }else{
            $("#type_attr").show();
            if (is_diyseo_htmlpath == 1) {
                $('#dl_dirname').hide();
            } else {
                $('#dl_dirname').show();
            }
        }
        if (6 == channel){
            $('#dl_typearcrank').hide();
        }else{
            $('#dl_typearcrank').show();
        }
        // 重新定义模板变量，专用于新建模板功能
        $.ajax({
            url: "{:url('Help/ajax_getTemplateList', ['_ajax'=>1])}",
            type: 'GET',
            dataType: 'JSON',
            data: {},
            success: function(res){
                if (res.code == 1) {
                    templateList = res.data.templateList;
                }
            }
        });
        // end

        if (templateList[channel] == undefined || templateList[channel] == '') {
            showErrorMsg('模板文件不存在！');
            return false;
        } else if (templateList[channel]['msg'] != '') {
            $('#notic_current_channel').html(templateList[channel]['msg']);
        }

        $('#templist').html(templateList[channel]['lists']);
        if ($.inArray(channel, js_allow_channel_arr) == -1) {
            if (channel == 6) {
                $('#dl_templist').find('label[for=templist]').html('<em>*</em>单页模板');
                var rulelistObj = $('input[name=rulelist]');
                if (rulelistObj.val() == '' || '{栏目目录}/list_{tid}_{page}.html' == rulelistObj.val() || '{typedir}/list_{tid}_{page}.html' == rulelistObj.val()) {
                    rulelistObj.val('{栏目目录}/index.html');
                }
                $('#rule_tips_2').hide();
            } else if (channel == 8) {
                $('#dl_templist').find('label[for=templist]').html('<em>*</em>留言模板');
                var rulelistObj = $('input[name=rulelist]');
                if (rulelistObj.val() == '' || '{栏目目录}/list_{tid}_{page}.html' == rulelistObj.val() || '{typedir}/list_{tid}_{page}.html' == rulelistObj.val()) {
                    rulelistObj.val('{栏目目录}/index.html');
                }
                $('#rule_tips_2').hide();
            }else if (51 == channel) {
                $('#dl_templist').hide();
                $('#dl_rulelist').hide();
            }
            $('#dl_tempview').hide();
            $('#dl_ruleview').hide();
        } else {
            $('#rule_tips_2').show();
            $('#dl_templist').find('label[for=templist]').html('<em>*</em>栏目模板');
            $('#dl_tempview').show();

            var is_diyseo_htmlpath = {$is_diyseo_htmlpath|default=0};
            var seo_html_pagename = {$seo_html_pagename|default=2};
            if (is_diyseo_htmlpath == 1 && seo_html_pagename == 4) {
                $('#dl_ruleview').show();
            }
        }
        $('#tempview').html(templateList[channel]['view']);

        $('.font_nid').html(templateList[channel]['nid']);

        return false;
    }
    /*--end*/

    function get_dirpinyin(obj)
    {
        return true;

        // var typename = $('input[name=typename]').val();
        // if ($.trim(typename) == '') {
        //     showErrorMsg('先填写栏目名称！');
        //     $('input[name=typename]').focus();
        //     return false;
        // }
        // $(obj).html('正在处理');
        // $.ajax({
        //     url: "{:url('Arctype/ajax_get_dirpinyin', ['_ajax'=>1])}",
        //     type: 'POST',
        //     dataType: 'JSON',
        //     data: {typename: typename},
        //     success: function(res){
        //         $(obj).html('获取拼音');
        //         if (res.code == 1) {
        //             var diy_dirpath = $('#dirpath').val() + '/' + res.data.pinyin;
        //             $('#diy_dirpath').val(diy_dirpath);
        //             return true;
        //         } else {
        //             showErrorMsg('操作失败');
        //             return false;
        //         }
        //     },
        //     error: function(e){
        //         $(obj).html('获取拼音');
        //         showErrorMsg(e.responseText);
        //         return false;
        //     }
        // });
    }

    function check_submit(){
        if($('input[name="typename"]').val() == ''){
            showErrorMsg('栏目名称不能为空！');
            $('input[name=typename]').focus();
            return false;
        }
        // if ($('input[name=is_part]:checked').val() == 1) {
        //     if($('input[name=typelink]').val() == ''){
        //         showErrorMsg('外部链接不能为空！');
        //         $('input[name=typelink]').focus();
        //         return false;
        //     }
        // }
        // var dirname = $('input[name="dirname"]').val();
        // var patrn = /^\d+$/;
        // if (patrn.test(dirname) == true) {
        //     showErrorMsg('目录名称不能为纯数字！');
        //     $('input[name=dirname]').focus();
        //     return false;
        // }
        //
        // var channel = 1;
        // if($('#templist').val() == '' && 51 != channel){
        //     $('.tab-base').find('.tab').each(function(){
        //         $(this).removeClass('current');
        //     });
        //     $($('.tab-base').find('.tab').get(1)).addClass('current');
        //     $('.tab_div_1').hide();
        //     $('.tab_div_2').show();
        //     showErrorMsg('请选择栏目模板');
        //     $('#templist').focus();
        //     return false;
        // }

        // var js_allow_channel_arr = {$js_allow_channel_arr};
        // if($('#tempview').val() == '' && $.inArray(channel, js_allow_channel_arr) != -1){
        //     $('.tab-base').find('.tab').each(function(){
        //         $(this).removeClass('current');
        //     });
        //     $($('.tab-base').find('.tab').get(1)).addClass('current');
        //     $('.tab_div_1').hide();
        //     $('.tab_div_2').show();
        //     showErrorMsg('请选择文档模板');
        //     $('#tempview').focus();
        //     return false;
        // }

        layer_loading('正在处理');
        if(!ajax_check_dirpath())
        {
            layer.closeAll();
            showErrorMsg('文件保存目录已存在！');
            $('input[name=dirpath]').focus();
            return false;
        }
        $('#post_form').submit();
    }

    function ajax_check_dirpath()
    {
        return true;
        /*
                var flag = false;
                var dirpath = $.trim($('input[name=dirpath]').val());
                $.ajax({
                    url: "{:url('Arctype/ajax_check_dirpath', ['_ajax'=>1])}",
                    type: 'POST',
                    async: false,
                    dataType: 'JSON',
                    data: {dirpath: dirpath, id: $('#id').val()},
                    success: function(res){
                        if(res.status == 1){
                            flag = true;
                        }
                    },
                    error: function(e){}
                });

                return flag;
                */
    }

    function img_call_back(fileurl_tmp)
    {
        $("#litpic_local").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }

    function newtpl(type)
    {
        var nid = $('#current_channel').find('option:selected').attr('data-nid');
        var url = "{:url('Arctype/ajax_newtpl')}";
        if (url.indexOf('?') > -1) {
            url += '&';
        } else {
            url += '?';
        }
        url += 'type='+type+'&nid='+nid;

        if ('lists' == type) {
            var title = '新建栏目模板';
        } else {
            var title = '新建文档模板';
        }
        //iframe窗
        layer.open({
            type: 2,
            title: title,
            fixed: true, //不固定
            shadeClose: false,
            shade: layer_shade,
            closeBtn: 3,
            maxmin: true, //开启最大化最小化按钮
            area: ['90%', '90%'],
            content: url
        });
    }
</script>

{include file="public/footer" /}